package com.iflytek.jobs.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.iflytek.jobs.service.domain.ComInfo;
import com.iflytek.jobs.service.service.IComInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 公司信息Controller
 * 
 * @author chenhs
 * @date 2023-02-06
 */
@RestController
@RequestMapping("/jobs/INFO")
public class ComInfoController extends BaseController
{
    @Autowired
    private IComInfoService comInfoService;

    /**
     * 查询公司信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ComInfo comInfo)
    {
        startPage();
        List<ComInfo> list = comInfoService.selectComInfoList(comInfo);
        return getDataTable(list);
    }

    /**
     * 导出公司信息列表
     */
    @Log(title = "公司信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @PreAuthorize("@ss.notRole('demo')")
    public void export(HttpServletResponse response, ComInfo comInfo)
    {
        List<ComInfo> list = comInfoService.selectComInfoList(comInfo);
        ExcelUtil<ComInfo> util = new ExcelUtil<ComInfo>(ComInfo.class);
        util.exportExcel(response, list, "公司信息数据");
    }

    /**
     * 获取公司信息详细信息
     */

    @GetMapping(value = "/{comId}")
    public AjaxResult getInfo(@PathVariable("comId") String comId)
    {
        return success(comInfoService.selectComInfoByComId(comId));
    }

    /**
     * 新增公司信息
     */
   @PreAuthorize("@ss.notRole('demo')")
    @Log(title = "公司信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ComInfo comInfo)
    {
        return toAjax(comInfoService.insertComInfo(comInfo));
    }

    /**
     * 修改公司信息
     */
   @PreAuthorize("@ss.notRole('demo')")
    @Log(title = "公司信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ComInfo comInfo)
    {
        return toAjax(comInfoService.updateComInfo(comInfo));
    }

    /**
     * 删除公司信息
     */
   @PreAuthorize("@ss.notRole('demo')")
    @Log(title = "公司信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{comIds}")
    public AjaxResult remove(@PathVariable String[] comIds)
    {
        return toAjax(comInfoService.deleteComInfoByComIds(comIds));
    }
}
